class Any {
    public:
        Any():_content(NULL) {}
        template<typename T>
        Any(const T &val) : _content(new holder<T>(val)){}
        Any(const Any &other): _content(other._content?other._content->clone() : NULL) {}
        ~Any() { if (_content) delete _content; }
        const std::type_info &type() { return _content ? _content->type() : typeid(void); }
        template<typename T>
        T* get() {
            assert(typeid(T) == _content->type());
            return &((holder<T>*)_content)->val;
        }
        Any& operator=(const Any &other) {
            _content = other._content ? other._content->clone() : NULL;
            return *this;
        }
        
    private:
        class placeholder {
            public:
                virtual ~placeholder() {}
                virtual const std::type_info &type()  = 0;
                virtual placeholder *clone() = 0;
        };
        template <typename T>
        class holder : public placeholder {
            public:
                holder(const T &v):val(v) {}
                ~holder() {}
                const std::type_info &type() { return typeid(T); }
                placeholder *clone() { return new holder(val); }
            public:
                T val;
        };
        placeholder *_content;
};